home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1998 May / macformat-063.iso / mac / Shareware Plus / Development / Object Plant 1.45 / Object Plant / Object Plant.rsrc / TEXT_128_EPS prep.txt < prev    next >
Encoding:
Text File  |  1997-12-14  |  54.5 KB  |  2,135 lines

  1.  
  2. /RE
  3. {
  4.     findfont begin
  5.     currentdict dup length dict begin
  6.     {
  7.         1 index /FID ne {def}{pop pop}ifelse
  8.     }forall
  9.     /FontName exch def dup length 0 ne
  10.     {
  11.         /Encoding Encoding 256 array copy def
  12.         0 exch
  13.         {
  14.             dup type /nametype eq
  15.             {
  16.                 Encoding 2 index 2 index put
  17.                 pop 1 add
  18.             }
  19.             {
  20.                 exch pop
  21.             }ifelse
  22.         }forall
  23.     }if pop
  24.     currentdict dup end end
  25.     /FontName get exch definefont pop
  26. } bind def
  27.  
  28. /stdencoding [
  29. 39/quotesingle 96/grave 128/Adieresis/Aring/Ccedilla/Eacute/Ntilde/Odieresis
  30. /Udieresis/aacute/agrave/acircumflex/adieresis/atilde/aring/ccedilla/eacute
  31. /egrave/ecircumflex/edieresis/iacute/igrave/icircumflex/idieresis/ntilde
  32. /oacute/ograve/ocircumflex/odieresis/otilde/uacute/ugrave/ucircumflex
  33. /udieresis/dagger/degree/cent/sterling/section/bullet/paragraph/germandbls
  34. /registered/copyright/trademark/acute/dieresis/.notdef/AE/Oslash
  35. /.notdef/plusminus/.notdef/.notdef/yen/mu/.notdef/.notdef
  36. /.notdef/.notdef/.notdef/ordfeminine/ordmasculine/.notdef/ae/oslash
  37. /questiondown/exclamdown/logicalnot/.notdef/florin/.notdef/.notdef
  38. /guillemotleft/guillemotright/ellipsis/.notdef/Agrave/Atilde/Otilde/OE/oe
  39. /endash/emdash/quotedblleft/quotedblright/quoteleft/quoteright/divide
  40. /.notdef/ydieresis/Ydieresis/fraction/currency/guilsinglleft/guilsinglright
  41. /fi/fl/daggerdbl/periodcentered/quotesinglbase/quotedblbase/perthousand
  42. /Acircumflex/Ecircumflex/Aacute/Edieresis/Egrave/Iacute/Icircumflex
  43. /Idieresis/Igrave/Oacute/Ocircumflex/.notdef/Ograve/Uacute/Ucircumflex
  44. /Ugrave/dotlessi/circumflex/tilde/macron/breve/dotaccent/ring/cedilla
  45. /hungarumlaut/ogonek/caron
  46. ] def
  47. stdencoding /_Helvetica /Helvetica RE
  48. stdencoding /_Helvetica-Oblique /Helvetica-Oblique RE
  49. stdencoding /_Helvetica-Bold /Helvetica-Bold RE
  50. stdencoding /_Helvetica-BoldOblique /Helvetica-BoldOblique RE
  51.  
  52. /Monaco10 /_Helvetica findfont 10 scalefont def
  53. /MonacoI10 /_Helvetica-Oblique findfont 10 scalefont def
  54. /MonacoB10 /_Helvetica-Bold findfont 10 scalefont def
  55. /MonacoBI10 /_Helvetica-BoldOblique findfont 10 scalefont def
  56. /Monaco9 /_Helvetica findfont 9 scalefont def
  57. /MonacoI9 /_Helvetica-Oblique findfont 9 scalefont def
  58.  
  59. /defaultHeight 30 def /ifDefaultHeight 40 def /defaultWidth 60 def
  60. /pointSize 3 def /diamondWidth 8 def /pyramidWidth 18 def
  61. /eventBoxWidth 9 def
  62.  
  63. /drawClassBox    % oper1 ... opern noOfOpers attr1 ... attrn noOfAttrs name abstract nested
  64. {
  65.     50 dict begin
  66.     /nested exch def /abstract exch def
  67.     /name exch def
  68.  
  69.     false abstract eq { MonacoB10 setfont }{ MonacoBI10 setfont } ifelse
  70.  
  71.     /maxwidth name stringwidth pop def
  72.     /boxwidth defaultWidth def
  73.  
  74.     /noOfAttr exch def /AttrArray noOfAttr array def /index noOfAttr 1 sub def {
  75.         index -1 eq { exit } if
  76.         AttrArray index 3 -1 roll put
  77.         /index index 1 sub def
  78.     } loop
  79.  
  80.     /noOfOper exch def /OperArray noOfOper array def /index noOfOper 1 sub def {
  81.         index -1 eq { exit } if
  82.         OperArray index 3 -1 roll put
  83.         /index index 1 sub def
  84.     } loop
  85.  
  86.     % Set font size for attributes an operations while checking boxwidth
  87.     false abstract eq { Monaco9 setfont }{ MonacoI9 setfont } ifelse
  88.     /leftmargin currentpoint pop def /topmargin currentpoint exch pop def
  89.     AttrArray {
  90.         stringwidth pop 8 add dup
  91.         maxwidth gt { /maxwidth exch def }{ pop } ifelse
  92.     } forall
  93.     OperArray {
  94.         stringwidth pop 8 add dup
  95.         maxwidth gt { /maxwidth exch def }{ pop } ifelse
  96.     } forall
  97.  
  98.     % Set back font size for the class name
  99.     false abstract eq { MonacoB10 setfont }{ MonacoBI10 setfont } ifelse
  100.     maxwidth boxwidth 6 sub gt { /boxwidth maxwidth 6 add def } if
  101.     noOfAttr 0 ne { /boxheight noOfAttr 12 mul 26 add def } if
  102.     noOfOper 0 ne { noOfAttr 0 ne { /boxheight boxheight 6 add noOfOper 12 mul add def }
  103.                                     { /boxheight noOfOper 12 mul 26 add def } ifelse } if
  104.     noOfOper 0 eq { noOfAttr 0 eq { /boxheight defaultHeight def } if } if
  105.     boxheight defaultHeight lt { /boxheight defaultHeight def } if
  106.     nested true eq { [3] 0 setdash } if
  107.     currentpoint boxwidth 0 rlineto
  108.     0 boxheight neg rlineto
  109.     boxwidth neg 0 rlineto closepath gsave 1 setgray fill grestore stroke
  110.     nested true eq { [] 0 setdash } if
  111.  
  112.     noOfAttr 0 ne { leftmargin topmargin -18 add moveto boxwidth 0 rlineto stroke } if
  113.  
  114.     noOfOper 0 ne
  115.     {
  116.         newpath noOfAttr 0 ne { leftmargin topmargin -24 add noOfAttr -12 mul add moveto }
  117.                                     { leftmargin topmargin -20 add moveto }ifelse
  118.         boxwidth 0 rlineto stroke
  119.     }if
  120.     moveto currentpoint
  121.     boxwidth name stringwidth pop sub 2 div -14 rmoveto name show
  122.  
  123.     false abstract eq { Monaco9 setfont }{ MonacoI9 setfont } ifelse
  124.     currentpoint /index 0 def
  125.     AttrArray
  126.     { 
  127.         leftmargin 8 add topmargin moveto
  128.         0 -12 index mul -30 add rmoveto show
  129.         /index index 1 add def
  130.     } forall
  131.     moveto currentpoint /index 0 def
  132.     OperArray
  133.     {
  134.         leftmargin 8 add topmargin moveto
  135.         noOfAttr 0 ne { 0 -12 index mul noOfAttr -12 mul add 38 sub rmoveto }
  136.         { 0 -12 index mul 32 sub rmoveto }ifelse show
  137.          /index index 1 add def
  138.     } forall
  139.     leftmargin boxwidth add topmargin boxheight sub
  140.     end
  141. } def
  142. /drawInterfaceBox    % oper1 ... opern noOfOpers attr1 ... attrn noOfAttrs name drawInterfaceBox
  143. {
  144.     50 dict begin
  145.     /name exch def
  146.  
  147.     MonacoB10 setfont
  148.  
  149.     /maxwidth name stringwidth pop def
  150.     /boxwidth defaultWidth def
  151.  
  152.     /noOfAttr exch def /AttrArray noOfAttr array def /index noOfAttr 1 sub def {
  153.         index -1 eq { exit } if
  154.         AttrArray index 3 -1 roll put
  155.         /index index 1 sub def
  156.     } loop
  157.  
  158.     /noOfOper exch def /OperArray noOfOper array def /index noOfOper 1 sub def {
  159.         index -1 eq { exit } if
  160.         OperArray index 3 -1 roll put
  161.         /index index 1 sub def
  162.     } loop
  163.  
  164.     % Set font size for attributes an operations while checking boxwidth
  165.     Monaco9 setfont
  166.     /leftmargin currentpoint pop def /topmargin currentpoint exch pop def
  167.     AttrArray {
  168.         stringwidth pop 8 add dup
  169.         maxwidth gt { /maxwidth exch def }{ pop } ifelse
  170.     } forall
  171.     OperArray {
  172.         stringwidth pop 8 add dup
  173.         maxwidth gt { /maxwidth exch def }{ pop } ifelse
  174.     } forall
  175.  
  176.     MonacoB10 setfont
  177.     maxwidth boxwidth 6 sub gt { /boxwidth maxwidth 6 add def } if
  178.     noOfAttr 0 ne { /boxheight noOfAttr 12 mul 36 add def } if
  179.     noOfOper 0 ne { noOfAttr 0 ne { /boxheight boxheight 6 add noOfOper 12 mul add def }
  180.                                     { /boxheight noOfOper 12 mul 36 add def } ifelse } if
  181.     noOfOper 0 eq { noOfAttr 0 eq { /boxheight ifDefaultHeight def } if } if
  182.     boxheight ifDefaultHeight lt { /boxheight ifDefaultHeight def } if
  183.     currentpoint boxwidth 0 rlineto
  184.     0 boxheight  neg  rlineto
  185.     boxwidth neg 0 rlineto closepath gsave 1 setgray fill grestore stroke
  186.  
  187.     noOfAttr 0 ne { leftmargin topmargin -28 add moveto boxwidth 0 rlineto stroke } if
  188.  
  189.     noOfOper 0 ne
  190.     {
  191.         newpath noOfAttr 0 ne { leftmargin topmargin -34 add noOfAttr -12 mul add moveto }
  192.                                     { leftmargin topmargin -28 add moveto }ifelse
  193.         boxwidth 0 rlineto stroke
  194.     }if
  195.     moveto currentpoint
  196.     boxwidth name stringwidth pop sub 2 div -24 rmoveto name show
  197.     leftmargin topmargin moveto
  198.     boxwidth (¬´interface¬ª) stringwidth pop sub 2 div -14 rmoveto (¬´interface¬ª) show
  199.  
  200.     Monaco9 setfont
  201.     currentpoint /index 0 def
  202.     AttrArray
  203.     { 
  204.         leftmargin 8 add topmargin 10 sub moveto
  205.         0 -12 index mul -30 add rmoveto show
  206.         /index index 1 add def
  207.     } forall
  208.     moveto currentpoint /index 0 def
  209.     OperArray
  210.     {
  211.         leftmargin 8 add topmargin 10 sub moveto
  212.         noOfAttr 0 ne { 0 -12 index mul noOfAttr -12 mul add 38 sub rmoveto }
  213.         { 0 -12 index mul 32 sub rmoveto }ifelse show
  214.          /index index 1 add def
  215.     } forall
  216.     leftmargin boxwidth add topmargin boxheight sub
  217.     end
  218. } def
  219.  
  220. /arrowdict 15 dict def
  221. arrowdict begin
  222. /mtrx matrix def
  223. end
  224.  
  225. /drawArrow %     tailx taily tipx tipy halfthickness halfheadthickness headlength dashed filled drawArrow
  226. { arrowdict begin
  227.     /filled exch def
  228.     /dashed exch def
  229.     /headlength exch def
  230.     /halfheadthickness exch 2 div def
  231.     /halfthickness exch 2 div def
  232.     /tipy exch def /tipx exch def
  233.     /taily exch def /tailx exch def
  234.  
  235.     /dx tipx tailx sub def
  236.     /dy tipy taily sub def
  237.     /arrowlength dx dx mul dy dy mul add sqrt def
  238.     /angle dy dx atan def
  239.     /arrowlength arrowlength headlength add def
  240.     /base arrowlength headlength sub def
  241.     /savematrix mtrx currentmatrix def
  242.     tailx taily translate
  243.     angle rotate
  244.     base halfthickness neg moveto
  245.     base halfheadthickness neg lineto
  246.     arrowlength 0 lineto
  247.     base halfheadthickness lineto
  248.     base halfthickness lineto
  249.     closepath
  250.     filled true eq { fill }{ gsave 1 setgray fill grestore stroke } ifelse
  251.     savematrix setmatrix
  252.     newpath 1 setlinewidth
  253.     tailx taily translate
  254.     angle rotate
  255.     dashed true eq { [3] 0 setdash }if
  256.     0 0 moveto base 0 lineto stroke
  257.     dashed true eq { [] 0 setdash }if
  258.     savematrix setmatrix
  259.     end
  260. } def
  261.  
  262. /navarrowdict 15 dict def
  263. navarrowdict begin
  264. /mtrx matrix def
  265. end
  266.  
  267. /drawNavArrow %     tailx taily tipx tipy halfthickness halfheadthickness headlength dashed drawNavArrow
  268. { navarrowdict begin
  269.     /dashed exch def
  270.     /headlength exch def
  271.     /halfheadthickness exch 2 div def
  272.     /halfthickness exch 2 div def
  273.     /tipy exch def /tipx exch def
  274.     /taily exch def /tailx exch def
  275.  
  276.     /dx tipx tailx sub def
  277.     /dy tipy taily sub def
  278.     /arrowlength dx dx mul dy dy mul add sqrt halfthickness sub def
  279.     /angle dy dx atan def
  280.     /base arrowlength headlength sub def
  281.     /savematrix mtrx currentmatrix def
  282.     tailx taily translate
  283.     angle rotate
  284.     base halfheadthickness neg moveto
  285.     arrowlength 0 lineto
  286.     base halfheadthickness lineto
  287.     0 setgray stroke
  288.     savematrix setmatrix
  289.     newpath 1 setlinewidth
  290.     tailx taily translate
  291.     angle rotate
  292.     dashed true eq { [3] 0 setdash }if
  293.     0 0 moveto arrowlength 0 lineto stroke
  294.     dashed true eq { [] 0 setdash }if
  295.     savematrix setmatrix
  296.     end
  297. } def
  298.  
  299. /drawAssoc    % pointn ... point1 noOfPoints branchRole branchMultText branchMult branchQualPos branchQual branchNavi baseRole baseMultText baseMult baseQualPos baseQual baseNavi name
  300. {
  301.     50 dict begin
  302.     Monaco9 setfont
  303.  
  304.     /name exch def /baseNavi exch def /baseQual exch def /baseQualPos exch def /baseMult exch def /baseMultText exch def /baseRole exch def
  305.     /branchNavi exch def /branchQual exch def /branchQualPos exch def /branchMult exch def /branchMultText exch def /branchRole exch def
  306.     /noOfPoints exch def /pntArray noOfPoints 2 mul array def /index 0 def
  307.     {
  308.         index noOfPoints 2 mul eq { exit } if
  309.         pntArray index 3 -1 roll put
  310.         /index index 1 add def
  311.     } loop
  312.  
  313. % Get the base qualifier's position
  314.     
  315.     /baseQualTW baseQual stringwidth pop def
  316.     /p1.h pntArray noOfPoints 1 sub 2 mul 1 add get def
  317.     /p1.v pntArray noOfPoints 1 sub 2 mul get def
  318.     /connect.h p1.h def
  319.     /connect.v p1.v def
  320.     baseQualPos 1 eq
  321.     {    % to the left of the first point
  322.         baseMult 1 eq {
  323.             /connect.h connect.h pointSize 2 div 2 add add def
  324.         } if
  325.         baseMult 2 eq {
  326.             /connect.h connect.h pointSize 2 div 2 add add def
  327.         } if
  328.     } if
  329.     baseQualPos 2 eq
  330.     {    % above the first point
  331.         baseMult 1 eq {
  332.             /connect.v connect.v pointSize 2 div 2 add sub def
  333.         } if
  334.         baseMult 2 eq {
  335.             /connect.v connect.v pointSize 2 div 2 add sub def
  336.         } if
  337.     } if
  338.     baseQualPos 3 eq
  339.     {    % to the right of the first point
  340.         baseMult 1 eq {
  341.             /connect.h connect.h pointSize 2 div 2 add sub def
  342.         } if
  343.         baseMult 2 eq {
  344.             /connect.h connect.h pointSize 2 div 2 add sub def
  345.         } if
  346.     } if
  347.     baseQualPos 4 eq
  348.     {    % below the first point
  349.         baseMult 1 eq {
  350.             /connect.v connect.v pointSize 2 div 2 add add def
  351.         } if
  352.         baseMult 2 eq {
  353.             /connect.v connect.v pointSize 2 div 2 add add def
  354.         } if
  355.     } if
  356.     baseQualPos 1 eq
  357.     {    % to the left of the first point
  358.         /p1.h connect.h baseQualTW 5 add sub def
  359.         /p1.v connect.v 3 sub def 
  360.     } if
  361.     baseQualPos 2 eq
  362.     {    % above the first point
  363.         /p1.h connect.h baseQualTW 2 div sub def
  364.         /p1.v connect.v 4 add def 
  365.     } if
  366.     baseQualPos 3 eq
  367.     {    % to the right of the first point
  368.         /p1.h connect.h 6 add def
  369.         /p1.v connect.v 3 sub def 
  370.     } if
  371.     baseQualPos 4 eq
  372.     {    % below the first point
  373.         /p1.h connect.h baseQualTW 2 div sub def
  374.         /p1.v connect.v 10 sub def
  375.     } if
  376.     /baseQualText.h p1.h def
  377.     /baseQualText.v p1.v def
  378.  
  379.     baseNavi 1 eq {
  380.         /p1.h pntArray noOfPoints 1 sub 2 mul 1 add get def
  381.         /p1.v pntArray noOfPoints 1 sub 2 mul get def
  382.         /p2.h pntArray noOfPoints 2 sub 2 mul 1 add get def
  383.         /p2.v pntArray noOfPoints 2 sub 2 mul get def
  384.         p2.h p2.v p1.h p1.v 1 5 5 false drawNavArrow
  385.     }if
  386.     branchNavi 1 eq {
  387.         /p1.h pntArray 1 get def
  388.         /p1.v pntArray 0 get def
  389.         /p2.h pntArray 3 get def
  390.         /p2.v pntArray 2 get def
  391.         p2.h p2.v p1.h p1.v 1 5 5 false drawNavArrow
  392.     }if
  393.  
  394.     /lineConnect.h connect.h def
  395.     /lineConnect.v connect.v def
  396.  
  397. % Determine the qualifiers rectangle size
  398.     baseQualTW 0 ne
  399.     {
  400.         baseQualPos 1 eq
  401.         {    % to the left of the first class
  402.             /RectRight connect.h def
  403.             /RectLeft baseQualText.h 5 sub def
  404.             /lineConnect.h RectLeft def
  405.             /RectTop baseQualText.v 12 add def
  406.             /RectBottom RectTop 16 sub def
  407.         } if
  408.         baseQualPos 3 eq
  409.         {    % to the right of the first class
  410.             /RectLeft connect.h def
  411.             /RectRight baseQualText.h baseQualTW 5 add add def
  412.             /lineConnect.h RectRight def
  413.             /RectTop baseQualText.v 12 add def
  414.             /RectBottom RectTop 16 sub def
  415.         } if
  416.         baseQualPos 2 eq
  417.         {    % above the first point
  418.             /RectBottom connect.v def
  419.             /RectTop RectBottom 16 add def
  420.             /lineConnect.v RectTop def
  421.             /RectLeft baseQualText.h 4 sub def
  422.             /RectRight RectLeft baseQualTW 9 add add def
  423.         } if
  424.         baseQualPos 4 eq
  425.         {    % below the first point
  426.             /RectTop connect.v def
  427.             /RectBottom RectTop 16 sub def
  428.             /lineConnect.v RectBottom def
  429.             /RectLeft baseQualText.h 4 sub def
  430.             /RectRight RectLeft baseQualTW add 9 add def
  431.         } if
  432.         RectLeft RectTop moveto
  433.         RectRight RectTop lineto
  434.         RectRight RectBottom lineto
  435.         RectLeft RectBottom lineto
  436.         closepath stroke
  437.         newpath
  438.         baseQualText.h baseQualText.v moveto
  439.         baseQual show
  440.     } if
  441.  
  442.     newpath 1 setlinewidth 0 setgray
  443.     /index 0 def
  444.     {
  445.         index noOfPoints eq { exit } if
  446.         pntArray index 2 mul 1 add get pntArray index 2 mul get
  447.         index noOfPoints 1 sub eq { pop pop lineConnect.h lineConnect.v } if
  448.         index 0 eq { moveto }{ lineto } ifelse
  449.         /index index 1 add def
  450.     } loop
  451.     stroke
  452.     /circle.h pntArray noOfPoints 1 sub 2 mul 1 add get def
  453.     /circle.v pntArray noOfPoints 1 sub 2 mul get def
  454.     baseQualTW 0 ne
  455.     {
  456.         baseQualPos 1 eq
  457.         {    % to the left of the first class
  458.             /circle.h circle.h baseQualTW 9 add sub def
  459.         } if
  460.         baseQualPos 3 eq
  461.         {    % to the right of the first class
  462.             /circle.h circle.h baseQualTW 11 add add def
  463.         } if
  464.         baseQualPos 2 eq
  465.         {    % above the first point
  466.             /circle.v circle.v 16 add def
  467.         } if
  468.         baseQualPos 4 eq
  469.         {    % below the first point
  470.             /circle.v circle.v 16 sub def
  471.         } if
  472.     } if
  473.     circle.h circle.v
  474.     baseMult 1 eq {
  475.         % hollow circle
  476.         pointSize 0.5 sub 0 360 arc stroke
  477.         circle.h circle.v
  478.         pointSize 1 sub 0 360 arc 1 setgray fill
  479.     } if
  480.     baseMult 2 eq {
  481.         % filled circle
  482.         pointSize 0.5 sub 0 360 arc gsave stroke grestore 0 setgray fill
  483.     } if
  484.  
  485.     0 setgray /p1.h pntArray noOfPoints 1 sub 2 mul 1 add get def
  486.     /p1.v pntArray noOfPoints 1 sub 2 mul get def
  487.     /p2.h pntArray noOfPoints 2 sub 2 mul 1 add get def
  488.     /p2.v pntArray noOfPoints 2 sub 2 mul get def
  489.     /roletextwidth baseRole stringwidth pop def
  490.  
  491.     p1.h p2.h eq
  492.     { p1.v p2.v le
  493.         { p1.h 5 add p1.v 4 add baseQualTW 0 ne { 14 add } if }
  494.         { p1.h 5 add p1.v 10 sub baseQualTW 0 ne { 14 sub } if } ifelse
  495.     }
  496.     { p1.v p2.v eq
  497.         { p1.h p2.h gt
  498.                 { p1.h roletextwidth 5 add sub baseQualTW 0 ne { baseQualTW 9 add sub } if p1.v 10 sub }
  499.                 { p1.h 6 add baseQualTW 0 ne { baseQualTW 7 add add } if p1.v 10 sub } ifelse
  500.         }
  501.         {    p1.v p2.v le
  502.             {    p1.h p2.h gt
  503.                 { p1.h roletextwidth 5 add sub p1.v 4 add baseQualTW 0 ne { 14 add } if }
  504.                 { p1.h 6 add p1.v 4 add baseQualTW 0 ne { 14 add } if } ifelse
  505.             }
  506.             {    p1.h p2.h gt
  507.                 { p1.h roletextwidth 5 add sub p1.v 10 sub baseQualTW 0 ne { 14 sub } if }
  508.                 { p1.h 6 add p1.v 10 sub baseQualTW 0 ne { 14 sub } if } ifelse
  509.             } ifelse
  510.         } ifelse
  511.     } ifelse
  512.     moveto baseRole show
  513.     /p1.h pntArray noOfPoints 1 sub 2 mul 1 add get def
  514.     /p1.v pntArray noOfPoints 1 sub 2 mul get def
  515.     /p2.h pntArray noOfPoints 2 sub 2 mul 1 add get def
  516.     /p2.v pntArray noOfPoints 2 sub 2 mul get def
  517.     /multtextwidth baseMultText stringwidth pop def
  518.  
  519.     p1.h p2.h eq
  520.     { p1.v p2.v le
  521.             {    p1.h multtextwidth 5 add sub p1.v 4 add baseQualTW 0 ne { 14 add } if }
  522.             {    p1.h multtextwidth 5 add sub p1.v 10 sub baseQualTW 0 ne { 14 sub } if } ifelse
  523.     }
  524.     { p1.v p2.v eq
  525.             { p1.h p2.h gt
  526.                     { p1.h multtextwidth 5 add sub baseQualTW 0 ne { baseQualTW 9 add sub } if p1.v 4 add }
  527.                     { p1.h 5 add baseQualTW 0 ne { baseQualTW 7 add add } if p1.v 4 add } ifelse
  528.             }
  529.             { p1.v p2.v le
  530.                     { p1.h p2.h gt
  531.                             { p1.h multtextwidth 5 add sub p1.v 4 add baseQualTW 0 ne { 14 add } if }
  532.                             { p1.h 5 add p1.v 4 add baseQualTW 0 ne { 14 add } if } ifelse
  533.                     }
  534.                     { p1.h p2.h gt
  535.                             { p1.h multtextwidth 5 add sub p1.v 10 sub baseQualTW 0 ne { 14 sub } if }
  536.                             { p1.h 5 add p1.v 10 sub baseQualTW 0 ne { 14 sub } if } ifelse
  537.                     } ifelse
  538.             } ifelse
  539.     } ifelse
  540.     moveto
  541.     baseMult 3 eq {
  542.         baseMultText show
  543.     } if
  544.  
  545.     newpath
  546.     % Get the branch qualifier's position
  547.  
  548.     /branchQualTW branchQual stringwidth pop def
  549.     /p1.h pntArray 1 get def
  550.     /p1.v pntArray 0 get def
  551.     /connect.h p1.h def
  552.     /connect.v p1.v def
  553.     branchQualPos 1 eq
  554.     {    % to the left of the first point
  555.         branchMult 1 eq {
  556.             /connect.h connect.h pointSize 2 div 2 add add def
  557.         } if
  558.         branchMult 2 eq {
  559.             /connect.h connect.h pointSize 2 div 2 add add def
  560.         } if
  561.         /p1.h connect.h branchQualTW 5 add sub def
  562.         /p1.v connect.v 3 sub def 
  563.     } if
  564.     branchQualPos 2 eq
  565.     {    % above the first point
  566.         branchMult 1 eq {
  567.             /connect.v connect.v pointSize 2 div 2 add sub def
  568.         } if
  569.         branchMult 2 eq {
  570.             /connect.v connect.v pointSize 2 div 2 add sub def
  571.         } if
  572.         /p1.h connect.h branchQualTW 2 div sub def
  573.         /p1.v connect.v 4 add def 
  574.     } if
  575.     branchQualPos 3 eq
  576.     {    % to the right of the first point
  577.         branchMult 1 eq {
  578.             /connect.h connect.h pointSize 2 div 2 add sub def
  579.         } if
  580.         branchMult 2 eq {
  581.             /connect.h connect.h pointSize 2 div 2 add sub def
  582.         } if
  583.         /p1.h connect.h 6 add def
  584.         /p1.v connect.v 3 sub def 
  585.     } if
  586.     branchQualPos 4 eq
  587.     {    % below the first point
  588.         branchMult 1 eq {
  589.             /connect.v connect.v pointSize 2 div 2 add add def
  590.         } if
  591.         branchMult 2 eq {
  592.             /connect.v connect.v pointSize 2 div 2 add add def
  593.         } if
  594.         /p1.h connect.h branchQualTW 2 div sub def
  595.         /p1.v connect.v 10 sub def
  596.     } if
  597.     /branchQualText.h p1.h def
  598.     /branchQualText.v p1.v def
  599.  
  600.     /lineConnect.h connect.h def
  601.     /lineConnect.v connect.v def
  602.  
  603. % Determine the qualifiers rectangle size
  604.     branchQualTW 0 ne
  605.     {
  606.         branchQualPos 1 eq
  607.         {    % to the left of the first class
  608.             /RectRight connect.h def
  609.             /RectLeft branchQualText.h 5 sub def
  610.             /lineConnect.h RectLeft def
  611.             /RectTop branchQualText.v 12 add def
  612.             /RectBottom RectTop 16 sub def
  613.         } if
  614.         branchQualPos 3 eq
  615.         {    % to the right of the first class
  616.             /RectLeft connect.h def
  617.             /RectRight branchQualText.h branchQualTW 5 add add def
  618.             /lineConnect.h RectRight def
  619.             /RectTop branchQualText.v 12 add def
  620.             /RectBottom RectTop 16 sub def
  621.         } if
  622.         branchQualPos 2 eq
  623.         {    % above the first point
  624.             /RectBottom connect.v def
  625.             /RectTop RectBottom 16 add def
  626.             /lineConnect.v RectTop def
  627.             /RectLeft branchQualText.h 4 sub def
  628.             /RectRight RectLeft branchQualTW 9 add add def
  629.         } if
  630.         branchQualPos 4 eq
  631.         {    % below the first point
  632.             /RectTop connect.v def
  633.             /RectBottom RectTop 16 sub def
  634.             /lineConnect.v RectBottom def
  635.             /RectLeft branchQualText.h 4 sub def
  636.             /RectRight RectLeft branchQualTW add 9 add def
  637.         } if
  638.         RectLeft RectTop moveto
  639.         RectRight RectTop lineto
  640.         RectRight RectBottom lineto
  641.         RectLeft RectBottom lineto
  642.         closepath gsave 1 setgray fill grestore stroke
  643.         newpath
  644.         branchQualText.h branchQualText.v moveto
  645.         branchQual show
  646.     } if
  647.     newpath
  648.     0 setgray
  649.     /circle.h pntArray 1 get def
  650.     /circle.v pntArray 0 get def
  651.     branchQualTW 0 ne
  652.     {
  653.         branchQualPos 1 eq
  654.         {    % to the left of the first class
  655.             /circle.h circle.h branchQualTW 9 add sub def
  656.         } if
  657.         branchQualPos 3 eq
  658.         {    % to the right of the first class
  659.             /circle.h circle.h branchQualTW 11 add add def
  660.         } if
  661.         branchQualPos 2 eq
  662.         {    % above the first point
  663.             /circle.v circle.v 16 add def
  664.         } if
  665.         branchQualPos 4 eq
  666.         {    % below the first point
  667.             /circle.v circle.v 16 sub def
  668.         } if
  669.     } if
  670.     circle.h circle.v
  671.     branchMult 1 eq {
  672.         % hollow circle
  673.         pointSize 0.5 sub 0 360 arc stroke
  674.         circle.h circle.v
  675.         pointSize 1 sub 0 360 arc 1 setgray fill
  676.     } if
  677.     branchMult 2 eq {
  678.         % filled circle
  679.         pointSize 0.5 sub 0 360 arc gsave stroke grestore 0 setgray fill
  680.     } if
  681.  
  682.     0 setgray
  683.     /p1.h pntArray 1 get def
  684.     /p1.v pntArray 0 get def
  685.     /p2.h pntArray 3 get def
  686.     /p2.v pntArray 2 get def
  687.     /roletextwidth branchRole stringwidth pop def
  688.  
  689.     p1.h p2.h eq
  690.     {    p1.v p2.v le
  691.         { p1.h 5 add p1.v 4 add branchQualTW 0 ne { 14 add } if }
  692.         { p1.h 5 add p1.v 10 sub branchQualTW 0 ne { 14 sub } if } ifelse
  693.     }
  694.     { p1.v p2.v eq
  695.         {    p1.h p2.h gt
  696.             { p1.h roletextwidth 5 add sub branchQualTW 0 ne { branchQualTW 9 add sub } if p1.v 10 sub }
  697.             { p1.h 5 add branchQualTW 0 ne { branchQualTW 7 add add } if p1.v 10 sub } ifelse
  698.         }
  699.         {    p1.v p2.v le
  700.             {    p1.h p2.h gt
  701.                 {    p1.h roletextwidth 5 add sub p1.v 4 add branchQualTW 0 ne { 14 add } if }
  702.                 {    p1.h 5 add p1.v 4 add branchQualTW 0 ne { 14 add } if } ifelse
  703.             }
  704.             {    p1.h p2.h gt
  705.                 {    p1.h roletextwidth 5 add add p1.v 0 sub branchQualTW 0 ne { 14 sub } if }
  706.                 {    p1.h 5 add p1.v 10 sub branchQualTW 0 ne { 14 sub } if } ifelse
  707.             } ifelse
  708.         } ifelse
  709.     } ifelse
  710.     moveto branchRole show
  711.     /p1.h pntArray 1 get def
  712.     /p1.v pntArray 0 get def
  713.     /p2.h pntArray 3 get def
  714.     /p2.v pntArray 2 get def
  715.     /multtextwidth branchMultText stringwidth pop def
  716.  
  717.     p1.h p2.h eq
  718.     { p1.v p2.v le
  719.         {    p1.h multtextwidth 5 add sub p1.v 4 add branchQualTW 0 ne { 14 add } if }
  720.         {    p1.h multtextwidth 5 add sub p1.v 10 sub branchQualTW 0 ne { 14 sub } if } ifelse
  721.      }
  722.      { p1.v p2.v eq
  723.             { p1.h p2.h gt
  724.                     { p1.h multtextwidth 5 add sub branchQualTW 0 ne { branchQualTW 9 add sub } if p1.v     4 add }
  725.                     { p1.h 5 add branchQualTW 0 ne { branchQualTW 7 add add } if p1.v 4 add } ifelse
  726.             }
  727.             { p1.v p2.v le
  728.                     { p1.h p2.h gt
  729.                             { p1.h multtextwidth 5 add sub p1.v 4 add branchQualTW 0 ne { 14 add } if }
  730.                             { p1.h 5 add p1.v 4 add branchQualTW 0 ne { 14 add } if } ifelse
  731.                     }
  732.                     { p1.h p2.h gt
  733.                             { p1.h multtextwidth 5 add sub p1.v 10 sub branchQualTW 0 ne { 14 sub } if }
  734.                             { p1.h 5 add p1.v 10 sub branchQualTW 0 ne { 14 sub } if } ifelse
  735.                     } ifelse
  736.             } ifelse
  737.     } ifelse
  738.     moveto
  739.     branchMult 3 eq {
  740.         branchMultText show
  741.     }if
  742.     end
  743. } def
  744.  
  745. /drawAggr    % [ pointn ... point1 noOfPoints branchRole branchMultText branchMult navigable ] noOfBranches 
  746.             % pointn ... point1 noOfPoints baseRole baseMultText baseMult navigable qualPos qualifier name byvalue diamondx diamondy
  747. {
  748.     70 dict begin
  749.     Monaco9 setfont
  750.  
  751.     /diay exch def
  752.     /diax exch def
  753.     /byvalue exch def
  754.     /name exch def /qualifier exch def /qualPos exch def /baseNavigable exch def /baseMult exch def /baseMultText exch def 
  755.     /baseRole exch def
  756.     /noOfStemPoints exch def
  757.     /stemArray noOfStemPoints 2 mul array def
  758.     /index 0 def
  759.     {
  760.         index noOfStemPoints 2 mul eq { exit } if
  761.         stemArray index 3 -1 roll put
  762.         /index index 1 add def
  763.     } loop
  764.  
  765. % Get the qualifier's position
  766.     
  767.     /qualTW qualifier stringwidth pop def
  768.     /p1.h stemArray noOfStemPoints 1 sub 2 mul 1 add get def
  769.     /p1.v stemArray noOfStemPoints 1 sub 2 mul get def
  770.     /connect.h p1.h def
  771.     /connect.v p1.v def
  772.     qualPos 1 eq
  773.     {    % to the left of the first point
  774.         /connect.h connect.h diamondWidth 0.5 add add def
  775.         /p1.h connect.h qualTW 5 add sub def
  776.         /p1.v connect.v 3 sub def 
  777.     } if
  778.     qualPos 2 eq
  779.     {    % above the first point
  780.         /connect.v connect.v diamondWidth 1 add sub def
  781.         /p1.h connect.h qualTW 2 div sub def
  782.         /p1.v connect.v 4 add def 
  783.     } if
  784.     qualPos 3 eq
  785.     {    % to the right of the first point
  786.         /connect.h connect.h diamondWidth sub def
  787.         /p1.h connect.h 6 add def
  788.         /p1.v connect.v 3 sub def 
  789.     } if
  790.     qualPos 4 eq
  791.     {    % below the first point
  792.         /connect.v connect.v diamondWidth 0.5 add add def
  793.         /p1.h connect.h qualTW 2 div sub def
  794.         /p1.v connect.v 10 sub def
  795.     } if
  796.     /qualText.h p1.h def
  797.     /qualText.v p1.v def
  798.  
  799.     /lineConnect.h connect.h def
  800.     /lineConnect.v connect.v def
  801.  
  802. % Determine the qualifiers rectangle size
  803.     qualTW 0 ne
  804.     {
  805.         qualPos 1 eq
  806.         {    % to the left of the first class
  807.             /RectRight connect.h def
  808.             /RectLeft qualText.h 5 sub def
  809.             /lineConnect.h RectLeft def
  810.             /RectTop qualText.v 12 add def
  811.             /RectBottom RectTop 16 sub def
  812.         } if
  813.         qualPos 3 eq
  814.         {    % to the right of the first class
  815.             /RectLeft connect.h def
  816.             /RectRight qualText.h qualTW 5 add add def
  817.             /lineConnect.h RectRight def
  818.             /RectTop qualText.v 12 add def
  819.             /RectBottom RectTop 16 sub def
  820.         } if
  821.         qualPos 2 eq
  822.         {    % above the first point
  823.             /RectBottom connect.v def
  824.             /RectTop RectBottom 16 add def
  825.             /lineConnect.v RectTop def
  826.             /RectLeft qualText.h 4 sub def
  827.             /RectRight RectLeft qualTW 9 add add def
  828.         } if
  829.         qualPos 4 eq
  830.         {    % below the first point
  831.             /RectTop connect.v def
  832.             /RectBottom RectTop 16 sub def
  833.             /lineConnect.v RectBottom def
  834.             /RectLeft qualText.h 4 sub def
  835.             /RectRight RectLeft qualTW add 9 add def
  836.         } if
  837.         RectLeft RectTop moveto
  838.         RectRight RectTop lineto
  839.         RectRight RectBottom lineto
  840.         RectLeft RectBottom lineto
  841.         closepath stroke
  842.         newpath
  843.         qualText.h qualText.v moveto
  844.         qualifier show
  845.     } if
  846.  
  847.     /noOfBranches exch def /branchesArray noOfBranches array def /index 0 def
  848.     {
  849.         index noOfBranches eq { exit } if
  850.         /branchNavigable exch def
  851.         /branchMult exch def /branchMultText exch def
  852.         /branchRole exch def /noOfBranchPoints exch def
  853.  
  854.         noOfBranchPoints 0 ne {
  855.             /pntArray noOfBranchPoints 2 mul array def
  856.             /pntIndex 0 def
  857.             {
  858.                 pntIndex noOfBranchPoints 2 mul eq { exit } if
  859.                 pntArray pntIndex 3 -1 roll put
  860.                 /pntIndex pntIndex 1 add def
  861.             } loop
  862.  
  863.             /branchArray 6 array def
  864.              branchArray 0 branchMult put branchArray 1 branchMultText put
  865.             branchArray 2 branchRole put branchArray 3 noOfBranchPoints put
  866.             branchArray 4 branchNavigable put branchArray 5 pntArray put
  867.          }
  868.          {
  869.              /branchArray 5 array def
  870.             branchArray 0 branchMult put branchArray 1 branchMultText put
  871.             branchArray 2 branchRole put branchArray 3 noOfBranchPoints put
  872.             branchArray 4 branchNavigable put
  873.         } ifelse
  874.         branchesArray index branchArray put
  875.         /index index 1 add def
  876.     } loop
  877.     newpath 1 setlinewidth 0 setgray
  878.  
  879.     /p1.h stemArray noOfStemPoints 1 sub 2 mul 1 add get def
  880.     /p1.v stemArray noOfStemPoints 1 sub 2 mul get def
  881.     /p2.h stemArray noOfStemPoints 2 sub 2 mul 1 add get def
  882.     /p2.v stemArray noOfStemPoints 2 sub 2 mul get def
  883.     baseNavigable 1 eq
  884.     {
  885.         p2.h p2.v p1.h p1.v 1 5 5 false drawNavArrow
  886.     }if
  887.  
  888.     /index 0 def
  889.     {
  890.         index noOfStemPoints eq { exit } if
  891.         stemArray index 2 mul 1 add get stemArray index 2 mul get
  892. %        index noOfStemPoints 1 sub eq { pop pop lineConnect.h lineConnect.v } if
  893.         index 0 eq { moveto }{ lineto } ifelse
  894.         /index index 1 add def
  895.     } loop
  896.     branchesArray
  897.     {
  898.         /branch exch def /branchMult branch 0 get def
  899.         /branchNavigable branch 4 get def
  900.         /branchMultText branch 1 get def /noOfPoints branch 3 get def
  901.         noOfPoints 0 ne {
  902.             /pntArray branch 5 get def
  903.             /index 0 def
  904.             {
  905.                 index noOfPoints eq { exit } if
  906.                 pntArray index 2 mul 1 add get pntArray index 2 mul get
  907.                 index 0 eq {
  908.                     branchNavigable 1 eq {
  909.                         pntArray 3 get pntArray 2 get pntArray 1 get pntArray 0 get 1 5 5 false drawNavArrow
  910.                     }if
  911.                     moveto
  912.                 }{
  913.                     lineto
  914.                 } ifelse
  915.                 /index index 1 add def
  916.             } loop
  917.         } if
  918.     }forall
  919.     stroke
  920.     branchesArray
  921.     {
  922.         /branch exch def
  923.         /branchMult branch 0 get def /branchMultText branch 1 get def
  924.         /branchRole branch 2 get def /noOfPoints branch 3 get def
  925.         noOfPoints 0 ne {
  926.             /pntArray branch 5 get def
  927.             newpath
  928.             /p1.h pntArray 1 get def /p1.v pntArray 0 get def
  929.             /p2.h pntArray 3 get def /p2.v pntArray 2 get def
  930.         }
  931.         {
  932.             newpath
  933.             /p1.h stemArray 1 get def /p1.v stemArray 0 get def
  934.             /p2.h stemArray 3 get def /p2.v stemArray 2 get def
  935.         } ifelse
  936.  
  937.         0 setgray
  938.  
  939.         p1.h p1.v
  940.         branchMult 1 eq {
  941.             % hollow circle
  942.             pointSize 0.5 sub 0 360 arc stroke
  943.             p1.h p1.v
  944.             pointSize 1 sub 0 360 arc 1 setgray fill
  945.         } if
  946.         branchMult 2 eq {
  947.             % filled circle
  948.             pointSize 0.5 sub 0 360 arc gsave stroke grestore 0 setgray fill
  949.         } if
  950.  
  951.         0 setgray
  952.         /roletextwidth branchRole stringwidth pop def
  953.  
  954.         p1.h p2.h eq
  955.         {    p1.v p2.v le
  956.             {    p1.h 5 add    p1.v 4 add }{ p1.h 5 add p1.v 10 sub } ifelse
  957.         }
  958.         { p1.v p2.v eq
  959.             {    p1.h p2.h gt
  960.                 { p1.h roletextwidth 5 add sub p1.v 10 sub }{ p1.h 5 add p1.v 10 sub } ifelse
  961.             }
  962.             {    p1.v p2.v le
  963.                 {    p1.h p2.h gt
  964.                     {    p1.h roletextwidth 5 add sub p1.v 4 add }{    p1.h 5 add p1.v 4 add } ifelse
  965.                 }
  966.                 {    p1.h p2.h gt
  967.                     {    p1.h roletextwidth 5 add add p1.v 0 sub }
  968.                     {    p1.h 5 add p1.v 10 sub } ifelse
  969.                 } ifelse
  970.             } ifelse
  971.         } ifelse
  972.         moveto branchRole show
  973.  
  974.         noOfPoints 0 ne {
  975.             /pntArray branch 5 get def
  976.             newpath
  977.             /p1.h pntArray 1 get def /p1.v pntArray 0 get def
  978.             /p2.h pntArray 3 get def /p2.v pntArray 2 get def
  979.         }
  980.         {
  981.             newpath
  982.             /p1.h stemArray 1 get def /p1.v stemArray 0 get def
  983.             /p2.h stemArray 3 get def /p2.v stemArray 2 get def
  984.         } ifelse
  985.         /multtextwidth branchMultText stringwidth pop def
  986.         0 setgray
  987.  
  988.         p1.h p2.h eq
  989.         { p1.v p2.v le
  990.             {    p1.h multtextwidth 5 add sub p1.v 4 add }
  991.             {    p1.h multtextwidth 5 add sub p1.v 10 sub }     ifelse
  992.         }
  993.         { p1.v p2.v eq
  994.             { p1.h p2.h gt
  995.                 { p1.h multtextwidth 5 add sub p1.v 4 add }{ p1.h 5 add p1.v 4 add } ifelse
  996.             }
  997.             { p1.v p2.v le
  998.                 { p1.h p2.h gt
  999.                     { p1.h multtextwidth 5 add sub p1.v 4 add }{ p1.h 5 add p1.v 4 add } ifelse
  1000.                 }
  1001.                 { p1.h p2.h gt
  1002.                     { p1.h multtextwidth 5 add sub p1.v 10 sub }{ p1.h 5 add p1.v 10 sub } ifelse
  1003.                 } ifelse
  1004.             } ifelse
  1005.         } ifelse
  1006.         moveto
  1007.         branchMult 3 eq {
  1008.             branchMultText show
  1009.         }if
  1010.  
  1011.     }forall
  1012.     stroke
  1013.  
  1014.     0 setgray
  1015.     /p1.h stemArray noOfStemPoints 1 sub 2 mul 1 add get def
  1016.     /p1.v stemArray noOfStemPoints 1 sub 2 mul get def
  1017.     /p2.h stemArray noOfStemPoints 2 sub 2 mul 1 add get def
  1018.     /p2.v stemArray noOfStemPoints 2 sub 2 mul get def
  1019.     /roletextwidth baseRole stringwidth pop def
  1020.  
  1021.     p1.h p2.h eq
  1022.     { p1.v p2.v le
  1023.         { p1.h 5 add p1.v 1 sub qualTW 0 ne { 14 add } if }
  1024.         { p1.h 5 add p1.v 1 sub qualTW 0 ne { 14 sub } if } ifelse
  1025.     }
  1026.     { p1.v p2.v eq
  1027.         { p1.h p2.h gt
  1028.                 { p1.h roletextwidth 1 sub sub qualTW 0 ne { qualTW 9 add sub } if p1.v 10 sub }
  1029.                 { p1.h 1 sub qualTW 0 ne { qualTW 7 add add } if p1.v 10 sub } ifelse
  1030.         }
  1031.         {    p1.v p2.v le
  1032.             {    p1.h p2.h gt
  1033.                 { p1.h roletextwidth 5 add sub p1.v 4 add qualTW 0 ne { 14 add } if }
  1034.                 { p1.h 6 add p1.v 4 add qualTW 0 ne { 14 add } if } ifelse
  1035.             }
  1036.             {    p1.h p2.h gt
  1037.                 { p1.h roletextwidth 5 add sub p1.v 10 sub qualTW 0 ne { 14 sub } if }
  1038.                 { p1.h 6 add p1.v 10 sub qualTW 0 ne { 14 sub } if } ifelse
  1039.             } ifelse
  1040.         } ifelse
  1041.     } ifelse
  1042.     moveto baseRole show
  1043.  
  1044.     newpath
  1045.     p1.h p2.h eq
  1046.     { p1.v p2.v le
  1047.             { p1.h p1.v 3 add qualTW 0 ne { 15 add } if }
  1048.             { p1.h p1.v 3 sub qualTW 0 ne { 16 sub } if } ifelse
  1049.     }
  1050.     { p1.v p2.v eq
  1051.             { p1.h p2.h gt
  1052.                     { p1.h 2 sub qualTW 0 ne { qualTW 10 add sub } if p1.v }
  1053.                     { p1.h 2 add qualTW 0 ne { qualTW 12 add add } if p1.v } ifelse
  1054.             }
  1055.             { p1.v p2.v le
  1056.                     { p1.h p2.h gt
  1057.                             { p1.h pointSize 5 add sub p1.v 4 add qualTW 0 ne { 15 add } if }
  1058.                             { p1.h 5 add p1.v 4 add qualTW 0 ne { 15 add } if } ifelse
  1059.                     }
  1060.                     { p1.h p2.h gt
  1061.                             { p1.h pointSize 5 add sub p1.v 10 sub qualTW 0 ne { 15 sub } if }
  1062.                             { p1.h 5 add p1.v 10 sub qualTW 0 ne { 15 sub } if } ifelse
  1063.                     } ifelse
  1064.             } ifelse
  1065.     } ifelse
  1066.     /y exch def
  1067.     /x exch def
  1068.     x y
  1069.     baseMult 1 eq {
  1070.         % hollow circle
  1071.         pointSize 0.5 sub 0 360 arc stroke
  1072.         x y
  1073.         pointSize 1 sub 0 360 arc 1 setgray fill
  1074.     } if
  1075.     baseMult 2 eq {
  1076.         % filled circle
  1077.         pointSize 0.5 sub 0 360 arc gsave stroke grestore 0 setgray fill
  1078.     } if
  1079.  
  1080.     /multtextwidth baseMultText stringwidth pop def
  1081.  
  1082.     p1.h p2.h eq
  1083.     { p1.v p2.v le
  1084.             {    p1.h multtextwidth 5 add sub p1.v 1 sub qualTW 0 ne { 14 add } if }
  1085.             {    p1.h multtextwidth 5 add sub p1.v 1 sub qualTW 0 ne { 14 sub } if }     ifelse
  1086.     }
  1087.     { p1.v p2.v eq
  1088.             { p1.h p2.h gt
  1089.                     { p1.h multtextwidth 1 sub sub qualTW 0 ne { qualTW 9 add sub } if p1.v 4 add }
  1090.                     { p1.h 1 sub qualTW 0 ne { qualTW 7 add add } if p1.v 4 add } ifelse
  1091.             }
  1092.             { p1.v p2.v le
  1093.                     { p1.h p2.h gt
  1094.                             { p1.h multtextwidth 5 add sub p1.v 4 add qualTW 0 ne { 14 add } if }
  1095.                             { p1.h 5 add p1.v 4 add qualTW 0 ne { 14 add } if } ifelse
  1096.                     }
  1097.                     { p1.h p2.h gt
  1098.                             { p1.h multtextwidth 5 add sub p1.v 10 sub qualTW 0 ne { 14 sub } if }
  1099.                             { p1.h 5 add p1.v 10 sub qualTW 0 ne { 14 sub } if } ifelse
  1100.                     } ifelse
  1101.             } ifelse
  1102.     } ifelse
  1103.     moveto
  1104.     baseMult 3 eq {
  1105.         baseMultText show
  1106.     } if
  1107.  
  1108.     newpath 1 setlinewidth
  1109.     qualTW 0 ne
  1110.     {
  1111.         qualPos 1 eq
  1112.         {
  1113.             /diax diax qualTW 9 add sub def
  1114.         } if
  1115.         qualPos 2 eq
  1116.         {
  1117.             /diay diay 16 add def
  1118.         } if
  1119.         qualPos 3 eq
  1120.         {
  1121.             /diax diax qualTW 11 add add def
  1122.         } if
  1123.         qualPos 4 eq
  1124.         {
  1125.             /diay diay 16 sub def
  1126.         } if
  1127.     } if
  1128.  
  1129.     diax diamondWidth 2 div sub 0.5 add diay moveto
  1130.  
  1131.     diamondWidth 2 div 1 sub diamondWidth 2 div 1 sub rlineto
  1132.     diamondWidth 2 div 1 sub diamondWidth 2 div 1 sub neg rlineto
  1133.     diamondWidth 2 div 1 sub neg diamondWidth 2 div 1 sub neg rlineto
  1134.     closepath
  1135.     byvalue 0 eq { 1 setgray }{ 0 setgray } ifelse fill
  1136.  
  1137.     newpath 1 setlinewidth 0 setgray
  1138.     diax diamondWidth 2 div sub diay moveto
  1139.  
  1140.     diamondWidth 2 div 0.5 sub diamondWidth 2 div 0.5 sub rlineto
  1141.     diamondWidth 2 div 0.5 sub diamondWidth 2 div 0.5 sub neg rlineto
  1142.     diamondWidth 2 div 0.5 sub neg diamondWidth 2 div 0.5 sub neg rlineto
  1143.     closepath stroke
  1144.  
  1145.     end
  1146. } def
  1147.  
  1148.  
  1149. /genarrowdict 15 dict def
  1150. genarrowdict begin
  1151. /mtrx matrix def
  1152. end
  1153.  
  1154. /drawGenArrow %     tailx taily tipx tipy halfthickness halfheadthickness headlength dashed filled drawGenArrow
  1155. { genarrowdict begin
  1156.     /filled exch def
  1157.     /dashed exch def
  1158.     /headlength exch def
  1159.     /halfheadthickness exch 2 div def
  1160.     /halfthickness exch 2 div def
  1161.     /tipy exch def /tipx exch def
  1162.     /taily exch def /tailx exch def
  1163.  
  1164.     /dx tipx tailx sub def
  1165.     /dy tipy taily sub def
  1166.     /arrowlength dx dx mul dy dy mul add sqrt halfthickness sub def
  1167.     /angle dy dx atan def
  1168.     /base arrowlength headlength sub def
  1169.     /savematrix mtrx currentmatrix def
  1170.     tailx taily translate
  1171.     angle rotate
  1172.     base halfthickness neg moveto
  1173.     base halfheadthickness neg lineto
  1174.     arrowlength 0 lineto
  1175.     base halfheadthickness lineto
  1176.     base halfthickness lineto
  1177.     closepath
  1178.     filled true eq { fill }{ gsave 1 setgray fill grestore stroke } ifelse
  1179.     savematrix setmatrix
  1180.     newpath 1 setlinewidth
  1181.     tailx taily translate
  1182.     angle rotate
  1183.     dashed true eq { [3] 0 setdash }if
  1184.     0 0 moveto base 0 lineto stroke
  1185.     dashed true eq { [] 0 setdash }if
  1186.     savematrix setmatrix
  1187.     end
  1188. } def
  1189.  
  1190. % [ pointn ... point1 noOfPoints branchRole branchMultText branchMult navigable ] noOfBranches pointn ... point1 noOfPoints baseRole baseMultText baseMult qualPos qualifier name pyramidorientation pyramidx pyramidy omtNotation
  1191. /drawGen
  1192. {
  1193.     50 dict begin
  1194.     Monaco9 setfont
  1195.  
  1196.     /omtNotation exch def
  1197.     /pyry exch def
  1198.     /pyrx exch def
  1199.     /orient exch def
  1200.     /name exch def
  1201.       /noOfStemPoints exch def
  1202.     /stemArray noOfStemPoints 2 mul array def
  1203.     /index 0 def
  1204.     {
  1205.         index noOfStemPoints 2 mul eq { exit } if
  1206.         stemArray index 3 -1 roll put
  1207.         /index index 1 add def
  1208.     } loop
  1209.  
  1210.     /noOfBranches exch def
  1211.     /branchesArray noOfBranches array def
  1212.  
  1213.     /index 0 def
  1214.     {
  1215.         index noOfBranches eq { exit } if
  1216.  
  1217.         /navigable exch def
  1218.         /branchMult exch def /branchMultText exch def
  1219.         /branchRole exch def /noOfBranchPoints exch def
  1220.  
  1221.         noOfBranchPoints 0 ne {
  1222.             /pntArray noOfBranchPoints 2 mul array def
  1223.             /pntIndex 0 def
  1224.             {
  1225.                 pntIndex noOfBranchPoints 2 mul eq { exit } if
  1226.                 pntArray pntIndex 3 -1 roll put
  1227.                 /pntIndex pntIndex 1 add def
  1228.             } loop
  1229.  
  1230.             /branchArray 2 array def
  1231.           branchArray 0 noOfBranchPoints put branchArray 1 pntArray put
  1232.         }
  1233.         {
  1234.             /branchArray 1 array def
  1235.           branchArray 0 noOfBranchPoints put
  1236.         } ifelse
  1237.         branchesArray index branchArray put
  1238.         /index index 1 add def
  1239.     } loop
  1240.     newpath 1 setlinewidth 0 setgray
  1241.     /index 0 def
  1242.     {
  1243.         index noOfStemPoints eq { exit } if
  1244.         stemArray index 2 mul 1 add get stemArray index 2 mul get
  1245.         index 0 eq { moveto }{ lineto } ifelse
  1246.         /index index 1 add def
  1247.     } loop
  1248.  
  1249.     branchesArray
  1250.     {
  1251.         /branch exch def
  1252.         /noOfPoints branch 0 get def
  1253.         noOfPoints 0 ne {
  1254.             /pntArray branch 1 get def
  1255.             /index 0 def
  1256.             {
  1257.                 index noOfPoints eq { exit } if
  1258.                 pntArray index 2 mul 1 add get pntArray index 2 mul get
  1259.                 index 0 eq { moveto }{ lineto } ifelse
  1260.                 /index index 1 add def
  1261.             } loop
  1262.         }if
  1263.     }forall
  1264.     stroke
  1265.  
  1266.     newpath
  1267.     pyrx pyry moveto
  1268.  
  1269.     omtNotation 1 eq {
  1270.         orient 0 eq {
  1271.             pyramidWidth 2 div 1.6 sub 0 rlineto
  1272.             pyramidWidth 2 div 1.6 sub neg pyramidWidth 2 div 1.6 sub rlineto
  1273.             pyramidWidth 2 div 1.6 sub neg pyramidWidth 2 div 1.6 sub neg rlineto
  1274.         } if
  1275.         orient 2 eq {
  1276.             0 pyramidWidth 2 div 1.6 sub rlineto
  1277.             pyramidWidth 2 div 1.6 sub neg pyramidWidth 2 div 1.6 sub neg rlineto
  1278.             pyramidWidth 2 div 1.6 sub pyramidWidth 2 div 1.6 sub neg rlineto
  1279.         } if
  1280.         orient 4 eq {
  1281.             pyramidWidth 2 div 1.6 sub neg 0 rlineto
  1282.             pyramidWidth 2 div 1.6 sub pyramidWidth 2 div 1.6 sub neg rlineto
  1283.             pyramidWidth 2 div 1.6 sub pyramidWidth 2 div 1.6 sub rlineto
  1284.         } if
  1285.         orient 6 eq {
  1286.             0 pyramidWidth 2 div 1.6 sub neg rlineto
  1287.             pyramidWidth 2 div 1.6 sub pyramidWidth 2 div 1.6 sub rlineto
  1288.             pyramidWidth 2 div 1.6 sub neg pyramidWidth 2 div 1.6 sub rlineto
  1289.         } if
  1290.         closepath 1 setgray fill
  1291.  
  1292.         newpath 1 setlinewidth 0 setgray
  1293.         pyrx pyry moveto
  1294.  
  1295.         orient 0 eq {
  1296.             pyramidWidth 2 div 0.5 sub 0 rlineto
  1297.             pyramidWidth 2 div 0.5 sub neg pyramidWidth 2 div 0.5 sub rlineto
  1298.             pyramidWidth 2 div 0.5 sub neg pyramidWidth 2 div 0.5 sub neg rlineto
  1299.         } if
  1300.         orient 2 eq {
  1301.             0 pyramidWidth 2 div 0.5 sub rlineto
  1302.             pyramidWidth 2 div 0.5 sub neg pyramidWidth 2 div 0.5 sub neg rlineto
  1303.             pyramidWidth 2 div 0.5 sub pyramidWidth 2 div 0.5 sub neg rlineto
  1304.         } if
  1305.         orient 4 eq {
  1306.             pyramidWidth 2 div 0.5 sub neg 0 rlineto
  1307.             pyramidWidth 2 div 0.5 sub pyramidWidth 2 div 0.5 sub neg rlineto
  1308.             pyramidWidth 2 div 0.5 sub pyramidWidth 2 div 0.5 sub rlineto
  1309.         } if
  1310.         orient 6 eq {
  1311.             0 pyramidWidth 2 div 0.5 sub neg rlineto
  1312.             pyramidWidth 2 div 0.5 sub pyramidWidth 2 div 0.5 sub rlineto
  1313.             pyramidWidth 2 div 0.5 sub neg pyramidWidth 2 div 0.5 sub rlineto
  1314.         } if
  1315.         closepath stroke
  1316.     }
  1317.     {
  1318.         /i noOfStemPoints 2 mul def
  1319.         stemArray i 3 sub get stemArray i 4 sub get stemArray i 1 sub get stemArray i 2 sub get 1 15 20 false false drawGenArrow
  1320.     } ifelse
  1321.     
  1322.     end
  1323. } def
  1324.  
  1325.  
  1326. /drawEventBox        % ulc.x ulc.y height
  1327. {
  1328.     50 dict begin
  1329.  
  1330.     /height exch def /ulcy exch def /ulcx exch def
  1331.  
  1332.     newpath 1 setlinewidth
  1333.     ulcx ulcy moveto eventBoxWidth 0 rlineto 0 height neg rlineto
  1334.     eventBoxWidth neg 0 rlineto closepath
  1335.     gsave stroke grestore
  1336.     1 setgray fill
  1337.     0 setgray fill
  1338.     end
  1339. } def
  1340.  
  1341. /drawEventThread    % ulc.x ulc.y height name
  1342. {
  1343.     50 dict begin
  1344.  
  1345.     /name exch def /height exch def /ulcy exch def /ulcx exch def
  1346.  
  1347.     newpath 1 setlinewidth
  1348.     Monaco10 setfont
  1349.     1 setlinewidth ulcx ulcy moveto 0 height neg rlineto stroke
  1350.     ulcx name stringwidth pop 2 div sub ulcy 10 add moveto name show
  1351.     end
  1352. } def
  1353.  
  1354. /drawEventEvent        % fulcx fulcy flrcx flrcy ulcx ulcy lrcx lrcy name dashed
  1355. {
  1356.     50 dict begin
  1357.  
  1358.     /dashed exch def /name exch def /lrcy exch def /lrcx exch def
  1359.     /ulcy exch def /ulcx exch def
  1360.     /flrcy exch def /flrcx exch def
  1361.     /fulcy exch def /fulcx exch def
  1362.  
  1363.     Monaco9 setfont
  1364.     newpath 1 setlinewidth
  1365.     ulcx ulcy lrcx lrcy 1 5 5 dashed true drawArrow
  1366.  
  1367.     fulcx flrcx gt
  1368.     {    % above to the left of p1
  1369.         /textx fulcx name stringwidth pop 3 add sub def
  1370.         /texty fulcy 2 add def
  1371.     }
  1372.     {    % above to the right of p1
  1373.         /textx fulcx 4 add def
  1374.         /texty fulcy 2 add def
  1375.     }ifelse
  1376.     textx texty moveto
  1377.     name show
  1378.     end
  1379. } def
  1380. /drawSupp        % pointn ... point1 noOfPoints name drawSupp
  1381. {
  1382.     50 dict begin
  1383.  
  1384.     /name exch def
  1385.     /noOfPoints exch def /pntArray noOfPoints 2 mul array def /index 0 def
  1386.     {
  1387.         index noOfPoints 2 mul eq { exit } if
  1388.         pntArray index 3 -1 roll put
  1389.         /index index 1 add def
  1390.     } loop
  1391.  
  1392.     Monaco9 setfont
  1393.     [3] 0 setdash
  1394.     newpath 1 setlinewidth
  1395.     noOfPoints 2 gt {
  1396.         /index 0 def
  1397.         {
  1398.             index noOfPoints 1 sub eq { exit } if
  1399.             /p1.h pntArray index 2 mul 1 add get def
  1400.             /p1.v pntArray index 2 mul get def
  1401.             /p2.h pntArray index 1 add 2 mul 1 add get def
  1402.             /p2.v pntArray index 1 add 2 mul get def
  1403.             p1.h p1.v moveto p2.h p2.v lineto stroke
  1404.             /index index 1 add def
  1405.         } loop
  1406.     } if
  1407.  
  1408.     /p1.h pntArray 1 get def
  1409.     /p1.v pntArray 0 get def
  1410.     /p2.h pntArray 3 get def
  1411.     /p2.v pntArray 2 get def
  1412.     [] 0 setdash
  1413.     p2.h p2.v p1.h p1.v 1 5 5 true drawNavArrow
  1414.  
  1415.     end
  1416. } def
  1417.  
  1418. /fourpops { pop pop pop pop } def
  1419. /drawRoundedBox % ulcx ulcy width height
  1420. {
  1421.     50 dict begin
  1422.  
  1423.     /height exch def /width exch def
  1424.     /ulcy exch def /ulcx exch def
  1425.  
  1426.     /lrcx ulcx width add def /lrcy ulcy height sub def
  1427.  
  1428.     ulcx lrcy 10 add moveto
  1429.     ulcx lrcy lrcx lrcy 5 arcto fourpops
  1430.     lrcx lrcy lrcx ulcy 5 arcto fourpops
  1431.     lrcx ulcy ulcx ulcy 5 arcto fourpops
  1432.     ulcx ulcy ulcx lrcy 5 arcto fourpops
  1433.     closepath
  1434.     gsave 1 setgray fill grestore stroke
  1435.     end
  1436. } def
  1437.  
  1438. /drawStateBox % actionn eventn .. action1 event1 noOfEvents exitlinen exitline1 noOfExitLines dolinen doline1 noOfDoLines entrylinen entryline1 noOfEntryLines name
  1439. {
  1440.     50 dict begin
  1441.  
  1442.     /boxheight 30 def
  1443.     /boxwidth 60 def
  1444.     /name exch def 
  1445.  
  1446. %
  1447. % Get all the entry/ lines and store them in entryLineArray
  1448. %
  1449.     /noOfEntryLines exch def
  1450.     /entryLineWidth 0 def     /entryHeight 0 def
  1451.     noOfEntryLines 0 ne
  1452.     { 
  1453.         /entryLineArray noOfEntryLines array def
  1454.         /entryLineIndex 0 def
  1455.         {
  1456.             entryLineIndex noOfEntryLines eq { exit } if
  1457.             entryLineArray entryLineIndex 3 -1 roll put
  1458.             /entryLineIndex entryLineIndex 1 add def
  1459.         } loop
  1460.         /entryHeight entryLineIndex 12 mul def
  1461.         /rubrikwidth MonacoI9 setfont (entry/ ) stringwidth pop def
  1462.         Monaco9 setfont
  1463.         entryLineArray
  1464.         {
  1465.             stringwidth pop dup rubrikwidth add 16 add
  1466.             entryLineWidth gt { /entryLineWidth exch def }{ pop } ifelse
  1467.         } forall
  1468.     } if
  1469.  
  1470. %
  1471. % Get all the do: lines and store them in doLineArray
  1472. %
  1473.     /noOfDoLines exch def
  1474.     /doLineWidth 0 def     /doHeight 0 def
  1475.     noOfDoLines 0 ne
  1476.     { 
  1477.         /doLineArray noOfDoLines array def
  1478.         /doLineIndex 0 def
  1479.         {
  1480.             doLineIndex noOfDoLines eq { exit } if
  1481.             doLineArray doLineIndex 3 -1 roll put
  1482.             /doLineIndex doLineIndex 1 add def
  1483.         } loop
  1484.         /doHeight doLineIndex 12 mul def
  1485.         /rubrikwidth Monaco9 setfont (do: ) stringwidth pop def
  1486.         doLineArray
  1487.         {
  1488.             stringwidth pop dup rubrikwidth add 16 add
  1489.             doLineWidth gt { /doLineWidth exch def }{ pop } ifelse
  1490.         } forall
  1491.     } if
  1492.  
  1493. %
  1494. % Get all the exit/ lines and store them in exitLineArray
  1495. %
  1496.     /noOfExitLines exch def
  1497.     /exitLineWidth 0 def     /exitHeight 0 def
  1498.     noOfExitLines 0 ne
  1499.     { 
  1500.         /exitLineArray noOfExitLines array def
  1501.         /exitLineIndex 0 def
  1502.         {
  1503.             exitLineIndex noOfExitLines eq { exit } if
  1504.             exitLineArray exitLineIndex 3 -1 roll put
  1505.             /exitLineIndex exitLineIndex 1 add def
  1506.         } loop
  1507.         /exitHeight exitLineIndex 12 mul def
  1508.         /rubrikwidth MonacoI9 setfont (exit/ ) stringwidth pop def
  1509.         Monaco9 setfont
  1510.         exitLineArray
  1511.         {
  1512.             stringwidth pop dup rubrikwidth add 16 add
  1513.             exitLineWidth gt { /exitLineWidth exch def }{ pop } ifelse
  1514.         } forall
  1515.     } if
  1516.  
  1517. %
  1518. % Get all the event/ lines and store each event in the eventsArray
  1519. % Each element of the eventsArray is another array where the first
  1520. % item holds the number of lines (following items)
  1521. %
  1522.     /noOfEvents exch def
  1523.     /eventHeight 0 def
  1524.     noOfEvents 0 ne
  1525.     { 
  1526.         /eventsArray noOfEvents array def
  1527.         /eventIndex 0 def
  1528.         {
  1529.             eventIndex noOfEvents eq { exit } if
  1530.             /noOfEventLines exch def
  1531.             /eventArray noOfEventLines 2 add array def
  1532.             eventArray 0 noOfEventLines put
  1533.             /lineIndex 1 def
  1534.             {
  1535.                 lineIndex noOfEventLines 2 add eq { exit } if
  1536.                 eventArray lineIndex 3 -1 roll put
  1537.                 /lineIndex lineIndex 1 add def
  1538.             } loop
  1539.             eventsArray eventIndex eventArray put
  1540.             /eventIndex eventIndex 1 add def
  1541.         } loop
  1542.  
  1543.         /eventLineWidth 0 def
  1544.  
  1545.         eventsArray
  1546.         {
  1547.             /ar exch def
  1548.             /noOfLines ar 0 get def
  1549.             /eventHeight eventHeight noOfLines add def
  1550.             /rubrikwidth ar noOfLines 1 add get MonacoI9 setfont stringwidth pop def
  1551.          Monaco9 setfont
  1552.             /item noOfLines def
  1553.             {
  1554.                 item 0 eq { exit } if
  1555.                 ar item get Monaco9 setfont stringwidth pop
  1556.                 rubrikwidth add 16 add dup
  1557.                 boxwidth gt { /boxwidth exch def }{ pop } ifelse
  1558.                 /item item 1 sub def
  1559.             } loop
  1560.         } forall
  1561.     /eventHeight eventHeight 10 mul def
  1562.     } if
  1563.  
  1564.     currentpoint /ulcy exch def /ulcx exch def
  1565.     /leftmargin currentpoint pop def /topmargin currentpoint exch pop def
  1566.  
  1567.     Monaco10 setfont
  1568.     name stringwidth pop dup 8 add
  1569.     boxwidth gt { /boxwidth exch def }{ pop } ifelse
  1570.  
  1571.     entryLineWidth boxwidth gt { /boxwidth entryLineWidth def } if
  1572.     doLineWidth boxwidth gt { /boxwidth doLineWidth def } if
  1573.     exitLineWidth boxwidth gt { /boxwidth exitLineWidth def } if
  1574.  
  1575.     30 exitHeight add doHeight add entryHeight add eventHeight add dup
  1576.     boxheight gt { /boxheight exch def }{ pop } ifelse
  1577.  
  1578. % Draw the name of the state
  1579.     Monaco10 setfont
  1580.     ulcx ulcy boxwidth boxheight drawRoundedBox
  1581.     ulcx boxwidth name stringwidth pop sub 2 div add
  1582.     ulcy 18 sub moveto name show
  1583.  
  1584.     /entryIndex 0 def
  1585.     entryHeight 0 ne
  1586.     {
  1587.         /item noOfEntryLines 1 sub def
  1588.         {
  1589.             item -1 eq { exit }if
  1590.             entryLineArray item get
  1591.             /item item 1 sub def
  1592.             ulcx 5 add ulcy 30 sub entryIndex 10 mul sub moveto
  1593.             entryIndex 0 eq { MonacoI9 setfont (entry/ ) show
  1594.                                                                 /leftmargin currentpoint pop ulcx 5 add sub def Monaco9 setfont }
  1595.                                                                 { leftmargin 0 rmoveto } ifelse
  1596.             show
  1597.             /entryIndex entryIndex 1 add def
  1598.         } loop
  1599.     } if
  1600.     Monaco9 setfont
  1601.     /doIndex 0 def
  1602.     doHeight 0 ne
  1603.     {
  1604.         /item noOfDoLines 1 sub def
  1605.         {
  1606.             item -1 eq { exit }if
  1607.             doLineArray item get
  1608.             /item item 1 sub def
  1609.             ulcx 5 add ulcy 30 sub doIndex 10 mul sub entryIndex 10 mul sub moveto
  1610.             doIndex 0 eq { (do: ) show /leftmargin currentpoint pop ulcx 5 add sub def }{ leftmargin 0 rmoveto } ifelse
  1611.             show
  1612.             /doIndex doIndex 1 add def
  1613.         } loop
  1614.     } if
  1615.  
  1616.     /eventIndex 0 def
  1617.     eventHeight 0 ne
  1618.     {
  1619.         /item noOfEvents 1 sub def
  1620.         {
  1621.             item -1 eq { exit }if
  1622.             /ar eventsArray item get def
  1623.             /item item 1 sub def
  1624.             /noOfLines ar 0 get def
  1625.             /lineIndex noOfLines 1 add def
  1626.             {
  1627.                 lineIndex 0 eq { exit } if
  1628.                 ar lineIndex get
  1629.                 ulcx 5 add ulcy 32 sub entryIndex 10 mul sub doIndex 10 mul sub eventIndex 10 mul sub moveto
  1630.                 lineIndex noOfLines 1 add eq
  1631.                 {
  1632.                     MonacoI9 setfont show ( ) show  /leftmargin currentpoint pop ulcx 5 add sub def
  1633.                     ar noOfLines get Monaco9 setfont show
  1634.                     /lineIndex lineIndex 2 sub def
  1635.                 }
  1636.                 {
  1637.                     leftmargin 0 rmoveto show
  1638.                     /lineIndex lineIndex 1 sub def
  1639.                 }ifelse
  1640.                 /eventIndex eventIndex 1 add def
  1641.             } loop
  1642.         } loop
  1643.     } if
  1644.  
  1645.     /exitIndex 0 def
  1646.     exitHeight 0 ne
  1647.     {
  1648.         /item noOfExitLines 1 sub def
  1649.         {
  1650.             item -1 eq { exit }if
  1651.             exitLineArray item get
  1652.             /item item 1 sub def
  1653.             ulcx 5 add ulcy 32 sub entryIndex 10 mul sub doIndex 10 mul sub eventIndex 10 mul sub exitIndex 10 mul sub moveto
  1654.             exitIndex 0 eq { MonacoI9 setfont (exit/ ) show
  1655.             /leftmargin currentpoint pop ulcx 5 add sub def
  1656.             Monaco9 setfont } { leftmargin 0 rmoveto }ifelse
  1657.             show
  1658.             /exitIndex exitIndex 1 add def
  1659.         } loop
  1660.     } if
  1661.     leftmargin boxwidth add topmargin boxheight sub
  1662.     end
  1663. } def
  1664.  
  1665. /drawStateEvent % [ pointn ... point1 ] noOfPoints eventtext
  1666.     50 dict begin
  1667.     Monaco9 setfont
  1668.  
  1669.     /eventtext exch def
  1670.  
  1671.     /noOfPoints exch def /pntArray noOfPoints 2 mul array def /index 0 def
  1672.     {
  1673.         index noOfPoints 2 mul eq { exit } if
  1674.         pntArray index 3 -1 roll put
  1675.         /index index 1 add def
  1676.     } loop
  1677.  
  1678.     newpath 1 setlinewidth 0 setgray
  1679.     /index 0 def
  1680.     {
  1681.         index noOfPoints eq { exit } if
  1682.         pntArray index 2 mul 1 add get pntArray index 2 mul get
  1683.         index 0 eq { moveto }{ lineto } ifelse
  1684.         /index index 1 add def
  1685.     } loop
  1686.     stroke
  1687.     pntArray noOfPoints 1 sub 2 mul 1 add get pntArray noOfPoints 1 sub 2 mul get
  1688.     pntArray noOfPoints 2 sub 2 mul 1 add get pntArray noOfPoints 2 sub 2 mul get
  1689.  
  1690. %
  1691. % Last line's x and y are on top of the stack
  1692. %
  1693.     /p1.v exch def
  1694.     /p1.h exch def
  1695.     /p2.v exch def
  1696.     /p2.h exch def
  1697.     /width eventtext stringwidth pop def
  1698.  
  1699.     p1.v p2.v eq
  1700.     {
  1701.         /p.v p1.v 7 add def
  1702.         p1.h p2.h lt
  1703.         {
  1704.             /p.h p1.h p2.h p1.h sub 2 div add  width 2 div   sub def
  1705.         }
  1706.         {
  1707.             /p.h p2.h p1.h p2.h sub 2 div add   width 2 div   sub def
  1708.         }ifelse
  1709.     }
  1710.     {
  1711.         p1.h p2.h eq
  1712.         {
  1713.             /p.h p1.h 5 add def
  1714.             p1.v p2.v ge
  1715.             {
  1716.                 /p.v p1.v p2.v p1.v sub 2 div add def
  1717.             }
  1718.             {
  1719.                 /p.v p2.v p1.v p2.v sub 2 div add def
  1720.             }ifelse
  1721.         }
  1722.         {
  1723.             p1.v p2.v ge
  1724.             {
  1725.                 /p.v  p1.v p2.v p1.v sub 2 div add def
  1726.             }
  1727.             {
  1728.                 /p.v  p2.v p1.v p2.v sub 2 div add def
  1729.             }ifelse
  1730.  
  1731.             p1.h p2.h lt
  1732.             {
  1733.                 /p.h  p1.h p2.h p1.h sub 2 div width 2 div sub add def
  1734.             }
  1735.             {
  1736.                 /p.h  p2.h p1.h p2.h sub 2 div width 2 div sub add def
  1737.             }ifelse
  1738.         }ifelse
  1739.     }ifelse
  1740.  
  1741.     MonacoI9 setfont
  1742.     p.h p.v moveto eventtext show
  1743.  
  1744.     pntArray 1 get pntArray 0 get
  1745.     /p1.v exch def /p1.h exch def
  1746.     pntArray 3 get pntArray 2 get
  1747.     /p2.v exch def /p2.h exch def
  1748.  
  1749.     p1.h p2.h eq
  1750.     {
  1751.         p1.v p2.v gt
  1752.         {
  1753.             /p1.v p1.v 5 sub def
  1754.         }
  1755.         {
  1756.             /p1.v p1.v 5 add def
  1757.         }ifelse
  1758.     }
  1759.     {
  1760.         p1.h p2.h gt
  1761.         {
  1762.             /p1.h p1.h 5 sub def
  1763.         }
  1764.         {
  1765.             /p1.h p1.h 5 add def
  1766.         }ifelse
  1767.     } ifelse
  1768.  p2.h p2.v p1.h p1.v 1 5 5 false true drawArrow
  1769.  
  1770.     end
  1771. } def
  1772.  
  1773. /drawNote %  linen line1 noOfLines width height drawNote
  1774. {
  1775.     50 dict begin
  1776.  
  1777.     /boxheight exch def
  1778.     /boxwidth exch def
  1779.  
  1780. %
  1781. % Get all the lines and store them in lineArray
  1782. %
  1783.     Monaco9 setfont
  1784.  
  1785.     /noOfLines exch def
  1786.     noOfLines 0 ne
  1787.     { 
  1788.         /lineArray noOfLines array def
  1789.         /lineIndex 0 def
  1790.         {
  1791.             lineIndex noOfLines eq { exit } if
  1792.             lineArray lineIndex 3 -1 roll put
  1793.             /lineIndex lineIndex 1 add def
  1794.         } loop
  1795.     } if
  1796.  
  1797.     currentpoint /ulcy exch def /ulcx exch def
  1798.  
  1799.     % compute max width of text lines
  1800.     /maxwidth 0 def
  1801.     noOfLines 0 ne
  1802.     {
  1803.         /item noOfLines 1 sub def
  1804.         {
  1805.             item -1 eq { exit }if
  1806.             lineArray item get
  1807.             stringwidth pop
  1808.             /width exch def
  1809.             maxwidth width lt { /maxwidth width def }if
  1810.             /item item 1 sub def
  1811.         } loop
  1812.     } if
  1813.     boxwidth maxwidth lt { /boxwidth maxwidth def }if
  1814.  
  1815.     % draw the box
  1816.     currentpoint boxwidth 0 rlineto
  1817.     0 boxheight neg rlineto
  1818.     boxwidth neg 0 rlineto closepath stroke
  1819.  
  1820.     % set clipping region
  1821.     gsave
  1822.     newpath
  1823.     ulcx 5 add ulcy moveto
  1824.     boxwidth 10 sub 0 rlineto
  1825.     0 boxheight neg rlineto
  1826.     boxwidth 10 sub neg 0 rlineto closepath clip
  1827.  
  1828.     /index 0 def
  1829.     noOfLines 0 ne
  1830.     {
  1831.         /item noOfLines 1 sub def
  1832.         {
  1833.             item -1 eq { exit }if
  1834.             lineArray item get
  1835.             /item item 1 sub def
  1836.             ulcx 5 add ulcy 12 sub index 10 mul sub moveto
  1837.             show
  1838.             /index index 1 add def
  1839.         } loop
  1840.     } if
  1841.     grestore
  1842.     newpath
  1843.     ulcx boxwidth add 14 sub ulcy moveto
  1844.     14 0 rlineto
  1845.     0 -10 rlineto closepath gsave stroke grestore 0.5 setgray fill
  1846.  
  1847.     2 setlinejoin
  1848.     ulcx boxwidth add 14 sub ulcy moveto
  1849.  
  1850.     ulcx boxwidth add 12 sub ulcy 3 sub        % x1, y1
  1851.     ulcx boxwidth add 11 sub ulcy 5 sub        % x2, y2
  1852.     ulcx boxwidth add 12 sub ulcy 10 sub    % x3, y3
  1853.     curveto
  1854.  
  1855.     ulcx boxwidth add 9 sub ulcy 8 sub    % x1, y1
  1856.     ulcx boxwidth add 4 sub ulcy 8 sub    % x2, y2
  1857.     ulcx boxwidth add ulcy 10 sub        % x3, y3
  1858.     curveto
  1859.  
  1860.     closepath gsave 1 setgray fill grestore 0 setgray stroke
  1861.     0 setlinejoin
  1862.  
  1863.     ulcx boxwidth add ulcy boxheight sub
  1864.  
  1865.     end
  1866. } def
  1867.  
  1868.  
  1869. /drawInitialState %  diameter x y drawInitialState
  1870. {
  1871.     50 dict begin
  1872.  
  1873.     /y exch def
  1874.     /x exch def
  1875.     /circleSize exch def
  1876.     newpath
  1877.     x circleSize 2 div add
  1878.     y circleSize 2 div sub
  1879.     circleSize 2 div
  1880.     0 360 arc
  1881.     closepath gsave stroke grestore fill
  1882.  
  1883.     end
  1884. } def
  1885.  
  1886. /drawFinalState %  diameter x y drawFinalState
  1887. {
  1888.     50 dict begin
  1889.  
  1890.     /y exch def
  1891.     /x exch def
  1892.     /circleSize exch def
  1893.     newpath
  1894.     x circleSize 2 div add
  1895.     y circleSize 2 div sub
  1896.     circleSize 2 div
  1897.     0 360 arc
  1898.     closepath stroke
  1899.     newpath
  1900.     x circleSize 2 div add
  1901.     y circleSize 2 div sub
  1902.     circleSize 2 div 3 sub
  1903.     0 360 arc
  1904.     closepath fill
  1905.  
  1906.     end
  1907. } def
  1908.  
  1909. /drawActor %  name
  1910. {
  1911.     50 dict begin
  1912.  
  1913.     /actorheight 75 def
  1914.     /actorwidth 30 def
  1915.     /name exch def 
  1916.  
  1917.     currentpoint /ulcy exch def /ulcx exch def
  1918.     /leftmargin currentpoint pop def /topmargin currentpoint exch pop def
  1919.  
  1920.     Monaco10 setfont
  1921.     /namewidth name stringwidth pop def
  1922.  
  1923.     /nameleft ulcx actorwidth 2 div add namewidth 2 div sub def
  1924.  
  1925. % Draw the name of the actor
  1926.     nameleft ulcy actorheight sub 5 add moveto name show
  1927.  
  1928. % Draw the stickman
  1929.     
  1930. % First head
  1931.     newpath
  1932.     ulcx actorwidth 2 div add    % x
  1933.     ulcy 10 sub                    % y
  1934.     10                            % r
  1935.     0 360 arc stroke
  1936.  
  1937. % then body
  1938.     newpath
  1939.     ulcx actorwidth 2 div add ulcy 20 sub moveto
  1940.     ulcx actorwidth 2 div add ulcy 20 sub actorheight 45 sub sub lineto
  1941.  
  1942. % then the legs
  1943.     actorwidth 2 div 1 sub neg -10 rlineto
  1944.     actorwidth 2 div 10 rmoveto
  1945.     actorwidth 2 div -10 rlineto
  1946.  
  1947. % then the arms
  1948.     ulcx ulcy 35 sub moveto
  1949.     actorwidth 2 div 5 rlineto
  1950.     actorwidth 2 div 1 sub -5 rlineto
  1951.     stroke
  1952.  
  1953.     leftmargin actorwidth add topmargin actorheight sub
  1954.     end
  1955. } def
  1956.  
  1957. /drawPackage %  name
  1958. {
  1959.     50 dict begin
  1960.  
  1961.     /packageheight 50 def
  1962.     /packagewidth 80 def
  1963.     /name exch def 
  1964.  
  1965.     currentpoint /ulcy exch def /ulcx exch def
  1966.     /leftmargin currentpoint pop def /topmargin currentpoint exch pop def
  1967.  
  1968.     Monaco10 setfont
  1969.     /namewidth name stringwidth pop def
  1970.  
  1971.     namewidth 6 add packagewidth gt { /packagewidth namewidth 6 add def } if
  1972.  
  1973.     /nameleft ulcx packagewidth 2 div add namewidth 2 div sub def
  1974.  
  1975.     ulcx ulcy 10 sub moveto
  1976.     ulcx packagewidth add ulcy 10 sub lineto
  1977.     ulcx packagewidth add ulcy packageheight sub 1 add lineto
  1978.     ulcx ulcy packageheight sub 1 add lineto
  1979.     closepath stroke
  1980.     newpath
  1981.     ulcx ulcy moveto
  1982.     ulcx 30 add ulcy lineto
  1983.     ulcx 30 add ulcy 10 sub lineto
  1984.     ulcx ulcy 10 sub lineto
  1985.     closepath stroke
  1986.  
  1987.     newpath
  1988.     nameleft ulcy 25 sub moveto
  1989.     name show
  1990.  
  1991.     leftmargin packagewidth add topmargin packageheight sub
  1992.     end
  1993. } def
  1994. /drawFrame %  width height
  1995. {
  1996.     50 dict begin
  1997.  
  1998.     /frameheight exch def
  1999.     /framewidth exch def
  2000.  
  2001.     currentpoint /ulcy exch def /ulcx exch def
  2002.     /leftmargin currentpoint pop def /topmargin currentpoint exch pop def
  2003.  
  2004.     ulcx framewidth add ulcy lineto
  2005.     ulcx framewidth add ulcy frameheight sub 1 add lineto
  2006.     ulcx ulcy frameheight sub 1 add lineto
  2007.     closepath stroke
  2008.  
  2009.     leftmargin framewidth add topmargin frameheight sub
  2010.     end
  2011. } def
  2012.  
  2013. /drawUseCase %  name
  2014. {
  2015.     50 dict begin
  2016.  
  2017.     /usecaseheight 50 def
  2018.     /usecasewidth 90 def
  2019.     /name exch def 
  2020.  
  2021.     currentpoint /ulcy exch def /ulcx exch def
  2022.     /leftmargin currentpoint pop def /topmargin currentpoint exch pop def
  2023.  
  2024.     Monaco10 setfont
  2025.     /namewidth name stringwidth pop def
  2026.  
  2027.     namewidth 6 add usecasewidth gt { /usecasewidth namewidth 6 add def } if
  2028.  
  2029.     /nameleft ulcx usecasewidth 2 div add namewidth 2 div sub def
  2030.  
  2031.     newpath
  2032.     ulcx usecasewidth 2 div add ulcy usecaseheight 2 div sub translate
  2033.     usecasewidth usecaseheight div 1 scale
  2034.     0 0 usecaseheight 2 div 0 360 arc
  2035.     usecaseheight usecasewidth div 1 scale
  2036.     ulcx usecasewidth 2 div add neg ulcy usecaseheight 2 div sub neg translate
  2037.     stroke
  2038.  
  2039.     newpath
  2040.     nameleft ulcy 25 sub moveto
  2041.     name show
  2042.  
  2043.     leftmargin usecasewidth add topmargin usecaseheight sub
  2044.     end
  2045. } def
  2046.  
  2047. /drawText %  linen line1 noOfLines typeface size drawText
  2048. {
  2049.     50 dict begin
  2050.  
  2051.     /size exch def
  2052.     /typeface exch def
  2053.  
  2054. %
  2055. % Get all the lines and store them in lineArray
  2056. %
  2057. %    stdencoding typeface RE findfont size scalefont def
  2058.     typeface findfont size scalefont setfont
  2059.  
  2060.     /noOfLines exch def
  2061.     noOfLines 0 ne
  2062.     { 
  2063.         /lineArray noOfLines array def
  2064.         /lineIndex 0 def
  2065.         {
  2066.             lineIndex noOfLines eq { exit } if
  2067.             lineArray lineIndex 3 -1 roll put
  2068.             /lineIndex lineIndex 1 add def
  2069.         } loop
  2070.     } if
  2071.  
  2072.     currentpoint /ulcy exch def /ulcx exch def
  2073.  
  2074.     % compute max width of text lines
  2075.     /maxwidth 0 def
  2076.     noOfLines 0 ne
  2077.     {
  2078.         /item noOfLines 1 sub def
  2079.         {
  2080.             item -1 eq { exit }if
  2081.             lineArray item get
  2082.             stringwidth pop
  2083.             /width exch def
  2084.             maxwidth width lt { /maxwidth width def }if
  2085.             /item item 1 sub def
  2086.         } loop
  2087.     } if
  2088.  
  2089.     /index 0 def
  2090.     noOfLines 0 ne
  2091.     {
  2092.         /item noOfLines 1 sub def
  2093.         {
  2094.             item -1 eq { exit }if
  2095.             lineArray item get
  2096.             /item item 1 sub def
  2097.             ulcx 5 add ulcy 12 sub index 10 mul sub moveto
  2098.             show
  2099.             /index index 1 add def
  2100.         } loop
  2101.     } if
  2102.  
  2103.     end
  2104. } def
  2105.  
  2106. /drawCommunicates    % pointn ... point1 noOfPoints name
  2107. {
  2108.     50 dict begin
  2109.     Monaco9 setfont
  2110.  
  2111.     /name exch def
  2112.     /noOfPoints exch def /pntArray noOfPoints 2 mul array def /index 0 def
  2113.     {
  2114.         index noOfPoints 2 mul eq { exit } if
  2115.         pntArray index 3 -1 roll put
  2116.         /index index 1 add def
  2117.     } loop
  2118.  
  2119.     newpath 1 setlinewidth 0 setgray
  2120.     /index 0 def
  2121.     {
  2122.         index noOfPoints eq { exit } if
  2123.         pntArray index 2 mul 1 add get pntArray index 2 mul get
  2124. %        index noOfPoints 1 sub eq { pop pop lineConnect.h lineConnect.v } if
  2125.         index 0 eq { moveto }{ lineto } ifelse
  2126.         /index index 1 add def
  2127.     } loop
  2128.     stroke
  2129.     end
  2130. } def
  2131.  
  2132. newpath 1 setlinewidth
  2133. 0 setgray
  2134.